<?php
$this->menu=array(
	array('label'=>'List export_information', 'url'=>array('list')),
	array('label'=>'Create export_information', 'url'=>array('create')),
	array('label'=>'Update export_information', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete export_information', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
);
?>

<h1>View export_information #<?php echo $model->id; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
            'data' => $model,
            'attributes' => array(
                'out_permit',
                'etd:date:Export date',
                'awb:text:AWB/BL',
                'vessel:text:Freight No./Vessel',
                'mode:text:Mode of Transport',
            ),
        )); ?>
<br />
<hr />

<?php $this->beginClip('packing_list_cargo'); ?>
<div id="packing-cargo-list">
<div>
    <?php echo CHtml::link('Back','#',array('id'=>'move','panel_id'=>'export_cargo'));?>
</div>
<div class="row">
    <?php echo CHtml::Label('searchText','search'); ?>
    <?php echo CHtml::TextField('search'); ?>
    <?php echo CHtml::link('Search','#',array('grid_id'=>'cargo-grid','id'=>'search')); ?>
</div>
<div class="row">
<?php
	$this->widget('zii.widgets.grid.CGridView',array(
			'id'=>"cargo-grid",
			'dataProvider'=>$cargo->NeedExport(),
			'columns'=>array(
				array(
					'value'=>'$data->in_date',
					'header'=>'Date received',
					'type'=>'date',
				),
				array(
					'class'=>'CLinkColumn',
					'header'=>'Marking',
					'labelExpression'=>'$data->marking',
					'urlExpression'=>'CHtml::normalizeUrl(array("cargo/view","id"=>$data->id))'
				),
				array(
					'value'=>'$data->consignee->cname',
					'header'=>'Consignee',
				),
				array(
					'header'=>'Dimension',
					'value'=>'$data->dimension->qty.$data->dimension->qty_type." / ".$data->dimension->wt.$data->dimension->wt_type." / ".$data->dimension->m3',
				),
				array(
					'class'=>'CLinkColumn',
					'label'=>'Add',
					'urlExpression'=>'CHtml::normalizeUrl(array("cargo_export/create","cargo_id"=>$data->id,"export_id"=>'.$model->id.'))',
					'linkHtmlOptions'=>array('id'=>'add_cargo'),
				),
			),
		));
?>

</div>
</div>
<?php $this->endClip(); ?>

<?php $this->beginClip('export_cargo'); ?>
<div>
    <?php echo CHtml::link('Choose cargo','#',array('id'=>'move','panel_id'=>'packing_list_cargo'));?>
</div>
<div id="cargo-list">
<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'report-list',
	'dataProvider'=>cargo_export::model()->in_export($model->id),
	'columns'=>array(
            'cargo.marking:text:Marking',
            'exporter',
            'consignee',
            'cargo.amt:number:Amount',
            array(
                'class'=>'CButtonColumn',
                'updateButtonUrl'=>'CHtml::normalizeUrl(array("cargo_export/update","id"=>$data->id))',
		'deleteButtonUrl'=>'CHtml::normalizeUrl(array("cargo_export/delete","id"=>$data->id))',
                'viewButtonUrl'=>'CHtml::normalizeUrl(array("cargo_export/Report","id"=>$data->id,"print"=>"print"))',
		'updateButtonOptions'=>array('id'=>'cargo-grid-update','dialog_width'=>'650'),
		'deleteButtonOptions'=>array('id'=>'remove_cargo'),
            )
	),
));
  
?>
</div>
<?php $this->endClip(); ?>
<?php $this->widget('application.widgets.RiotingNerds.panel',array(
	'id'=>'export_information-panel',
	'panel'=>array(
		'export_cargo'=>$this->clips['export_cargo'],
		'packing_list_cargo'=>$this->clips['packing_list_cargo'],
	)
))?>
<?php
$ExportReportUrl = CHtml::normalizeUrl(array('cargo_export/report/print/print'));
$script =<<<EOD
$('a#move').click(function(){
	$.winerdyPanel.MoveById('export_information-panel',$(this).attr('panel_id'));
	return false;
});
$('#cargo-grid #add_cargo').live('click',function(){
	var dialogButton = {
		Create:function(){
			var dialog = $(this);
			$.cargo_export_form_afterSubmit = {
				afterSubmit:function(data){
					$.fn.yiiGridView.update('cargo-grid');
					$.simplelogajax.popup('$ExportReportUrl?id='+data.id);
					$(dialog).dialog('close');
					$.fn.yiiGridView.update('report-list');
				}
			};
			$(this).find('form').find('[type=submit]').click();
		}
	};
	$.simplelogdialog({url:$(this).attr('href')},{width:600},dialogButton);
	return false;
});
$('#remove').live('click',function(){
	var response = confirm("Do you really want to delete this?");
	if(response == false)
		return false;
	var container = $(this).parents('.view');
	var form = $.extend($.simplelogform,{afterSubmit:function(data){
		$(container).hide('puff');
		$(container).remove();
	}});
	var params = [];
	params['id'] = $(this).attr('remove_id');
	form.Submit($('#export-information-view'),params);
	return false;
});
$('#ajaxPortlet li:first a').click(function(){
	$.simplelogdialog({url:$(this).attr('href')},{width:750});
	return false;
});
$('input#search').keypress(function(event){
	if(event.keyCode == '13'){
		$(this).next('a#search').click();
	}
});
$('a#search').click(function(){
	var searchInput = $(this).prev('input#search');
	$.fn.yiiGridView.update($(this).attr('grid_id'),{data:{searchText:$(searchInput).val()}});
	return false;
});
EOD;
$cs = Yii::app()->getClientScript();
$cs->registerScript('Export_information#View',$script);
?>